/**
 * @author xiaobyu
 * @created Mar 25, 2016
 * 
 */
package nconv.convert.generator;

import nconv.convert.ConvertUtils;
import nconv.convert.BaseWordConverter;
import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.model.StyleDescription;
import org.apache.poi.hwpf.model.StyleSheet;
import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.w3c.dom.Element;


public class StyleNameGenerator extends BaseWordConverter {

	public static void main(String[] args) throws Exception {
		//ConvertUtils.process("FD007890.doc", new StyleNameGenerator(), "style");
		ConvertUtils.process("29335-d00.doc", new StyleNameGenerator(), "style");
		//ConvertUtils.process("cgbu_eg_1036.doc", new StyleNameGenerator(), "style");
	}

	@Override
	protected void processParagraph(HWPFDocumentCore wordDocument, Element parentElement, int currentTableLevel,
	    Paragraph paragraph, String bulletText) {
		StyleSheet styleSheet = wordDocument.getStyleSheet();
    StyleDescription paragraphStyle = styleSheet.getStyleDescription(paragraph.getStyleIndex());
		String styleName = paragraphStyle.getName();
		parentElement.appendChild(textDocumentFacade.createText("=== " + styleName + " === " + paragraph.text()));
	}
	
	protected void outputCharacters(Element block, CharacterRun characterRun,
      String text) {
  }
}